/**
 * 此类专供与网络连接使用
 */

// 全局配置
import config from "../config/ConfigGlobal.js";

/**
 *  post 请求
 * @param api 请求api接口
 * @param param 参数拼接
 */
const httpPost = (api, param) => {
    return new Promise(async (resolve, reject) => {
        let getUrl = config.server_url + api;
        $.ajax({
            type: "POST",
            url: getUrl,
            data: JSON.stringify(param),
            async: false,  //同步
            contentType: 'application/json',
            beforeSend: function () {
                // console.info("show");
            },
            success: function (data) {
                resolve(data);
            },
            error: function (data) {
                console.log("异常信息" + JSON.stringify(data))
                reject(data)
            },
            complete: function () {
                // console.info("hide");
            }
        });
    })
}

export default {
    httpPost: httpPost,
}